package com.xiyue.leaspring.service.impl;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xiyue.leaspring.dao.IDeptDAO;
import com.xiyue.leaspring.po.Dept;
import com.xiyue.leaspring.service.IDeptService;

@Service
public class DeptServiceImpl implements IDeptService {

	@Autowired//注入IDeptDaos接口实例
	private IDeptDAO deptDao;
	
	public Dept add(Dept vo) {
		// TODO Auto-generated method stub
		return this.deptDao.save(vo);//增加实例
	}

	public List<Dept> getlist() {
		// TODO Auto-generated method stub
		return this.deptDao.findAll();//数据查询
	}

	@Override
	public Dept get(Long id) {
		// TODO Auto-generated method stub
		return this.deptDao.findById(id);
	}

	@Override
	public List<Dept> gets(Set<Long> ids) {
		// TODO Auto-generated method stub
		return this.deptDao.findByIds(ids);
	}

	@Override
	public Dept getIdAndDname(Dept dept) {
		// TODO Auto-generated method stub
		return this.deptDao.findByIdAndName(dept);
	}

	@Override
	public boolean edit(Dept dept) {
		// TODO Auto-generated method stub
		return this.deptDao.doEdit(dept)>0;
	}

	@Override
	public boolean remove(Long id) {
		// TODO Auto-generated method stub
		return this.deptDao.doRemove(id)>0;
	}

	@Override
	public List<Dept> getByDname(String dname) {
		// TODO Auto-generated method stub
		return this.deptDao.findByDname(dname);
	}
	
	@Override
	public List<Dept> getByDeptnoIn(Set<Long> ids){
		// TODO Auto-generated method stub
		return this.deptDao.findByIds(ids);
	}

	@Override
	public List<Dept> liestSearch(String keyword) {
		// TODO Auto-generated method stub
		return this.deptDao.findByDnameContainingOrderByDeptnoDesc(keyword);
	}
	
	

}
